home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’93
/
Johan
/
hm.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-17
|
2KB
|
136 lines
#define MAIN
#include "hm.h"
void doMenu(long menuAndItem);
void doKey(void);
void doMouse(void);
void doAbout(void);
void doAbout(void)
{
DialogPtr dlog = GetNewDialog(DLOG_About, 0, (DialogPtr)-1);
short itemHit;
do {
ModalDialog(0, &itemHit);
} while (itemHit == ok);
DisposeDialog(dlog);
}
void doMenu(long menuAndItem)
{
switch (HiWord(menuAndItem)) {
case MENU_Apple:
switch (LoWord(menuAndItem)) {
case item_about:
doAbout();
break;
}
break;
case MENU_File:
switch (LoWord(menuAndItem)) {
case item_quit:
done = true;
break;
}
break;
}
HiliteMenu(0);
}
void doKey(void)
{
if (theEvent.modifiers & cmdKey) {
doMenu(MenuKey(0xFF & theEvent.message));
}
}
void doMouse(void)
{
WindowPtr wind;
long newSize;
long menuAndItem;
short what;
switch (what = FindWindow(theEvent.where ,&wind)) {
case inContent:
case inDrag:
case inGrow:
case inGoAway:
case inZoomIn:
case inZoomOut:
if (wind != FrontWindow()) {
BringToFront(wind);
return;
}
}
switch (what) {
case inMenuBar:
doMenu(MenuSelect(theEvent.where));
break;
case inContent:
GlobalToLocal(&theEvent.where);
doMazeClick(theEvent.where, theEvent.modifiers);
break;
case inDrag:
SetPort(wind);
DragWindow(wind, theEvent.where, &dragBounds);
break;
case inGrow:
SetPort(wind);
newSize = GrowWindow(wind, theEvent.where, &sizeBounds);
if (newSize) {
SizeWindow(wind, LoWord(newSize), HiWord(newSize), false);
InvalRect(&wind->portRect);
}
break;
case inDesk:
case inSysWindow:
case inGoAway:
case inZoomIn:
case inZoomOut:
break;
}
}
void main(void)
{
init();
while (!done) {
if (WaitNextEvent(-1, &theEvent, 0, 0)) {
switch (theEvent.what) {
case mouseDown:
doMouse();
break;
case autoKey:
case keyDown:
doKey();
break;
case updateEvt:
SetPort((WindowPtr)theEvent.message);
BeginUpdate((WindowPtr)theEvent.message);
if ((WindowPtr)theEvent.message == mazeWindow) {
doMazeDraw();
}
EndUpdate((WindowPtr)theEvent.message);
break;
}
}
}
}